#include <iostream>
using namespace std;

#include<cstdlib>
#include<ctime>
#include<fstream>
#include<vector>

int main( int argc, char** argv ){
	
	
	
	
	
	int cardinality_R = atoi( argv[1] );
	int cardinality_L = atoi( argv[2] );
	int min_k = atof( argv[3] );
	int max_k = atof( argv[4] );
	int min_density = atoi( argv[5] );
	int max_density = atoi( argv[6] );
	
	int seed = atoi(argv[8]);
	srand( seed );
	
	vector<int> R(cardinality_R);
	for( int i = 0; i < cardinality_R; ++i )
		R[i] = i+1;
	
	
	vector< vector<int> > L;
	
	for( int i = 0; i < cardinality_L; ++i )
		L.push_back( vector<int>() );
	
	float d = ((float)(min_density+rand()%(max_density-min_density))/1000.0);
	//cout << d << endl;
	
	for( int i = 0; i < cardinality_L; ++i ){
		for( int j = 0; j < cardinality_R; ++j ){
			float r = (float)rand()/(float)RAND_MAX;
			if( r <= d ){
				L[i].push_back( R[j] );
			}
		}
	}
	
	float alfa = ((float)(min_k + rand()%(max_k-min_k))/1000.0);
	//cout << (int)(alfa*100) << endl;
	//exit(0);
	int k = alfa*(float)cardinality_L;
	
	ofstream out( argv[7], std::ofstream::out );
	
	out << k << " " << cardinality_L << endl;
	
	for( int i = 0; i < cardinality_L; ++i ){
		out << L[i].size() << endl;
		for( int j = 0; j < L[i].size(); ++j ){
			out << L[i][j] << " ";
		}
		out << endl;
	}
	
	out.close();
	
	
	
}